package com.Studen.servlet;

import com.Studen.Dao.DDLDao;
import com.Studen.Dao.DDLDaoMpl;
import com.Studen.Dao.LoginDaoMpl;
import com.Studen.bean.Score;
import com.Studen.bean.User;

import java.util.List;

public class DDLServletMpl implements DDLServlet{
    DDLDaoMpl ddlDaoMpl = new DDLDaoMpl();

    @Override
    public List<User> getamd(String adm) {
        return new DDLDaoMpl().getadm(adm);
    }

    @Override
    public List<Score> Update(int x, int id) {
        return ddlDaoMpl.Update(x,id);
    }

    @Override
    public List<User> InsertServlet(User user, int[] a) {
        new DDLDaoMpl().InsertDao(user,a);
        return new LoginDaoMpl().show();
    }

    @Override
    public List<User> Detect(int id) {
        DDLDao d = new DDLDaoMpl();
        d.del(id);
        return null;
    }

    @Override
    public List<User> file(User user) {
        DDLDao d=new DDLDaoMpl();
        List<User>file=d.file(user);
        if (file.size()<1){
            return null;
        }
        int i = file.get(0).getU_role();
        if (i==1){
            return new LoginDaoMpl().show();
        }
        return null;
    }

    @Override
    public List<User> Select(String str) {
        List<User>u = ddlDaoMpl.Select(str);
        //如果列表的长度不等于0、则说明数据库中有相对于的元组、如果列表的长度等于0、则没有元组
        if (u.isEmpty()){
                return null;
        }
        else {
            return u;
        }
    }

    @Override
    public List<Score> show(int show) {
        return ddlDaoMpl.show(show);
    }
}
